﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2021_6_4
{
    class Judgment
    {
        public string playerName;
        public int playerScore;
        public string npcName;
        public int npcScore;
        public int countBattle;

        public Judgment(string Player , string Npc)
        {
            this.playerName = Player;
            this.npcName = Npc;
        }
        public void Decide(janKenPunch player , janKenPunch npc)
        {
            //玩家出剪刀的情况
            if (player == janKenPunch.剪刀)
            {
                if (npc == janKenPunch.剪刀)
                {
                    countBattle++;
                    Console.WriteLine("和局");
                }
                else if (npc == janKenPunch.布)
                {
                    countBattle++;
                    playerScore++;
                    Console.WriteLine($"{playerName}胜！");
                }
                else
                {
                    countBattle++;
                    npcScore++;
                    Console.WriteLine($"{npcName}胜！");
                }
            }
            //出石头的情况
            else if (player == janKenPunch.石头)
            {
                if (npc == janKenPunch.石头)
                {
                    countBattle++;
                    Console.WriteLine("和局");
                }
                else if (npc == janKenPunch.剪刀)
                {
                    countBattle++;
                    playerScore++;
                    Console.WriteLine($"{playerName}胜！");
                }
                else
                {
                    countBattle++;
                    npcScore++;
                    Console.WriteLine($"{npcName}胜！");
                }
            }
            //出布的情况
            else 
            {
                if (npc == janKenPunch.布)
                {
                    countBattle++;
                    Console.WriteLine("和局");
                }
                else if (npc == janKenPunch.石头)
                {
                    countBattle++;
                    playerScore++;
                    Console.WriteLine($"{playerName}胜！");
                }
                else
                {
                    countBattle++;
                    npcScore++;
                    Console.WriteLine($"{npcName}胜！");
                }
            }
        }

        public override string ToString()
        {
            string result;

            if (playerScore > npcScore)
            {
                result = $"{playerName}赢！";
            }
            else if (playerScore < npcScore)
            {
                result = $"{npcName}赢！";
            }
            else
            {
                result = "但是谁也没有赢"; 
            }

            return $"{playerName} VS {npcName}\n对局次数：{countBattle}\r\n姓名\t得分\n{playerName}\t{playerScore}\n{npcName}\t{npcScore}\n" + result;
        }
    }
}
